package com.seo.proxy.context;

import java.nio.channels.SocketChannel;

import com.seo.async.HasClientContext;
import com.seo.proxy.Buffer;
import com.seo.proxy.http.HttpRequest;

public class RequestContext implements HasClientContext {

	private SocketChannel socketChannel;

	private HttpRequest httpRequest;

	private RequestState requestState;

	private Buffer requestBuffer = new Buffer(0x10000);

	private ClientContext clientContext;

	private String ip;

	public RequestContext(ClientContext clientContext, SocketChannel socketChannel) {
		this.clientContext = clientContext;
		this.socketChannel = socketChannel;
		this.httpRequest = new HttpRequest();
		this.requestState = new RequestState();
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public RequestState getRequestState() {
		return requestState;
	}

	public void setRequestState(RequestState requestState) {
		this.requestState = requestState;
	}

	public HttpRequest getHttpRequest() {
		return httpRequest;
	}

	@Override
	public ClientContext getClientContext() {
		return clientContext;
	}

	public SocketChannel getSocketChannel() {
		return socketChannel;
	}

	public void setSocketChannel(SocketChannel socketChannel) {
		this.socketChannel = socketChannel;
	}

	public Buffer getRequestBuffer() {
		return requestBuffer;
	}

	public void reset() {
		httpRequest = new HttpRequest();
		requestState = new RequestState();
	}
}
